package com.varian.auth.controller;

import com.varian.auth.model.dto.OAuth2CaptchaDTO;
import com.varian.auth.service.IOAuth2Service;
import com.varian.security.util.SecurityUtil;
import com.varian.service.web.BaseController;
import com.varian.tool.result.IR;
import com.varian.tool.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.PermitAll;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ben
 * @since 2024/7/26
 */
@RestController
@Tag(name = "OAuth2控制层")
@RequestMapping("/oauth2")
public class OAuth2Controller extends BaseController<IOAuth2Service> {

    @PermitAll
    @GetMapping("captcha")
    @Operation(summary = "获取验证码")
    public R<String> captcha(@Validated OAuth2CaptchaDTO dto) {
        return R.data(baseService.captcha(dto));
    }

    @GetMapping("user-info")
    @Operation(summary = "获取用户信息")
    public IR userInfo(){
        return R.data(SecurityUtil.getLoginUser());
    }

}
